﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/masAdmin.master" AutoEventWireup="true"
    CodeFile="AddRelatedItem.aspx.cs" Inherits="admin_AddRelatedItem" %>

<%@ Register Assembly="CommonTagTime" Namespace="CommonTagTime.PagerControl" TagPrefix="cc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="pagename" runat="Server">
    Add Related Items
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="content" runat="Server">
    <div class="content-box-header">
        <h3>Please enter the SKU of the item name that belongs to the family/collection below</h3>
    </div>
    <div class="content-box-content">
        <table id="tab1" class="table100" cellpadding="2" cellspacing="2">
            <tr>
                <td>
                </td>
                <td align="left" colspan="3">
                    <asp:ValidationSummary ID="vsumProduct" runat="server" ShowMessageBox="true" ShowSummary="false"
                        CssClass="errorMessage" />
                    <asp:Label ID="lblErrorMessage" runat="server" CssClass="errorMessage"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="width: 200px" align="right" valign="top">
                    SKU (<span class="commentRequireInputText">*</span>):
                </td>
                <td>
                    <asp:TextBox ID="txtSKU" runat="server" MaxLength="500" TextMode="MultiLine" Width="150px"
                        Height="120px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="reqSKU" runat="server" EnableClientScript="true"
                        CssClass="errorMessage" ErrorMessage="SKU is require" Display="Dynamic" ControlToValidate="txtSKU">*</asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="button" OnClick="btnAdd_Click" />
                    <asp:Button ID="btnBack" runat="server" Text="Back" CssClass="button" OnClick="btnBack_Click" />
                </td>
            </tr>
        </table>
    </div>
    <div id="divGrid" runat="server" class="box">
        <div class="pagination right">
            <cc1:Pager ID="Pager2" runat="server" OnPageIndexChanging="Pager2_PageIndexChanging"
                OnPageSizeChanging="Pager2_PageSizeChanging" />
        </div>
        <div>
            <asp:Button ID="btnDelete" Text="Delete" runat="server" CssClass="button" OnClientClick="return CheckDelete();"
                OnClick="btnDelete_Click" />
        </div>
        <asp:Repeater ID="rptData" runat="server" OnItemCommand="rptData_ItemCommand" OnItemDataBound="rptData_ItemDataBound">
            <HeaderTemplate>
                <table class="table100" border="0">
                    <thead>
                        <th class="gridCheckBoxColumHeader">
                            <input id="chkCheckAll" type="checkbox" onclick="CheckAll(this.checked)" />
                        </th>
                        <th class="gridNoColumHeader">
                            No.
                        </th>
                        <th style="width: 100px;">
                            SKU
                        </th>
                        <th class="align-left">
                            Name
                        </th>
                        <th style="width: 120px;">
                            Price
                        </th>
                        <th style="width: 120px;">
                            Order
                        </th>
                        <th class="gridActiveColumHeader">
                            Is Active</td>
                            <th class="gridActiveColumHeader">
                                Is New
                            </th>
                            <th class="griActionColumHeader">
                                Action
                            </th>
                    </thead>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td align="center">
                        <input type="checkbox" name="chk_<%#Eval("ProductId") %>" id="chk_<%#Eval("ProductId") %>"
                            onclick="CheckItem('<%#Eval("ProductId") %>',this.checked);" />
                    </td>
                    <td align="center">
                        <%#Container.ItemIndex + 1%>
                    </td>
                    <td align="center">
                        <%#Eval("SKU") %>
                    </td>
                    <td>
                        <%#Eval("Name") %>
                    </td>
                    <td align="right" style="padding-right: 30px;">
                        <%#string.Format(@"{0:N2}", Eval("NowPrice")) %>
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbOrderUp" runat="server" ImageUrl="~/App_Themes/Admin/images/downarrow.png"
                            CommandName="OrderUp" />
                        <asp:ImageButton ID="imbOrderDown" runat="server" ImageUrl="~/App_Themes/Admin/images/upnarrow.png"
                            CommandName="OrderDown" />
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbActive" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="Active" />
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbIsNew" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="New" />
                    </td>
                    <td align="center">
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit">
                            <img src="/App_Themes/Admin/images/icons/pencil.png" alt="Edit" title="Edit" />
                        </a>
                        <asp:ImageButton ID="imbDelete" runat="server" ImageUrl="~/App_Themes/Admin/images/cross_circle.png"
                            CommandName="Delete" />
                    </td>
                </tr>
            </ItemTemplate>
            <AlternatingItemTemplate>
                <tr class="alt-row">
                    <td align="center">
                        <input type="checkbox" name="chk_<%#Eval("ProductId") %>" id="chk_<%#Eval("ProductId") %>"
                            onclick="CheckItem('<%#Eval("ProductId") %>',this.checked);" />
                    </td>
                    <td align="center">
                        <%#Container.ItemIndex + 1%>
                    </td>
                    <td align="center">
                        <%#Eval("SKU") %>
                    </td>
                    <td>
                        <%#Eval("Name") %>
                    </td>
                    <td align="right" style="padding-right: 30px;">
                        <%#string.Format(@"{0:N}", Eval("NowPrice")) %>
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbOrderUp" runat="server" ImageUrl="~/App_Themes/Admin/images/downarrow.png"
                            CommandName="OrderUp" />
                        <asp:ImageButton ID="imbOrderDown" runat="server" ImageUrl="~/App_Themes/Admin/images/upnarrow.png"
                            CommandName="OrderDown" />
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbActive" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="Active" />
                    </td>
                    <td align="center">
                        <asp:ImageButton ID="imbIsNew" runat="server" ImageUrl="~/App_Themes/Admin/images/tick.png"
                            CommandName="New" />
                    </td>
                    <td align="center">
                        <a href="ProductDetail.aspx?id=<%#Eval("ProductId") %>&act=edit">
                            <img src="/App_Themes/Admin/images/icons/pencil.png" alt="Edit" title="Edit" />
                        </a>
                        <asp:ImageButton ID="imbDelete" runat="server" ImageUrl="~/App_Themes/Admin/images/cross_circle.png"
                            CommandName="Delete" />
                    </td>
                </tr>
            </AlternatingItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <div class="pagination">
            <cc1:Pager ID="Pager1" runat="server" OnPageIndexChanging="Pager2_PageIndexChanging"
                OnPageSizeChanging="Pager2_PageSizeChanging" />
        </div>
        <input type="hidden" value="" runat="server" id="hidProductID" />
        <input type="hidden" value="" runat="server" id="hidProductIDSelect" />
    </div>
    <div id="divEmplty" runat="server" visible="false">
    </div>
    <script type="text/javascript">
        function CheckAll(status) {
            var id = document.getElementById('<%=hidProductID.ClientID %>').value;
            var arr = new Array();
            arr = id.split(';');
            if (arr.length > 0) {
                for (var i = 0; i < arr.length; i++) {
                    if (document.getElementById('chk_' + arr[i].toString())) {
                        document.getElementById('chk_' + arr[i].toString()).checked = status;

                    }
                }

            }
            if (status) {
                document.getElementById('<%=hidProductIDSelect.ClientID %>').value = id;
            }
            else document.getElementById('<%=hidProductIDSelect.ClientID %>').value = '';

        }
        function CheckItem(id, status) {

            var idSelect = document.getElementById('<%=hidProductIDSelect.ClientID %>').value;
            if (status) {
                idSelect += id + ';';
            }
            else idSelect = idSelect.replace(id + ';', '');
            if (idSelect.length == document.getElementById('<%=hidProductID.ClientID %>').value.length) {
                document.getElementById('chkCheckAll').checked = true;
            }
            else
                document.getElementById('chkCheckAll').checked = false;
            document.getElementById('<%=hidProductIDSelect.ClientID %>').value = idSelect;

        }
        function ConfirmDelete() {
            var yes = confirm('<%=Resources.Resource.MSG_CONFIRM_DELETE %>');
            return yes;
        }
        function CheckDelete() {

            var id = document.getElementById('<%=hidProductIDSelect.ClientID %>').value;
            if (id == '') {
                alert('<%=Resources.Resource.MSG_REQUIRE_SELECT_ITEM %>');
                return false;
            }
            else return ConfirmDelete();
        }
       
    </script>
</asp:Content>
